import fetchData from "@/utils/fetchData";
import type {GetListArgs} from "@/service/entity/GetListArgs";
import type {DataBox} from "@/service/entity/DataBox";
import type {HosMo} from "@/service/entity/HosMo";
import type {HosCustomerDao} from "@/service/entity/HosCustomerDao";
import type {UserBindingCustomerMo} from "@/service/entity/UserBindingCustomerMo";
import type {PageListDto} from "@/service/entity/PageListDto";

const proxy = async (path: string, data?: any) => {
    return await fetchData('/srv-auth/admin/hos/' + path, data)
}

export const syncHos = async (): Promise<DataBox> => {
    return await proxy('syncHos')
}

export const getAllCustomerList = async (): Promise<{
    arr: HosCustomerDao[]
}> => {
    return await proxy('getAllCustomerList')
}

export const updateHosStatus = async (hosId: any, status: number): Promise<DataBox> => {
    return await proxy('updateHosStatus', {hosId, status})
}

export interface BindingHosToAppUserArgs {
    appId: any
    hosId: any[]
    uid: any[]
}

export const bindingHosToAppUser = async (args: BindingHosToAppUserArgs): Promise<DataBox> => {
    return await proxy('bindingHosToAppUser', args)
}

export const delBindingHos = async (appId: any, hosId: any): Promise<DataBox> => {
    return await proxy('delBindingHos', {appId, hosId})
}

export const getBindingHosList = async (args: GetListArgs): Promise<{
    arr: HosMo[]
    total: number
}> => {
    return await proxy('getBindingHosList', args)
}

export const getHosList = async (args: GetListArgs): Promise<{
    arr: HosMo[]
    total: number
}> => {
    return await proxy('getHosList', args)
}

export const getHosUids = async (appId: any, hosId: any): Promise<{
    arr: any[]
}> => {
    return await proxy('getHosUids', {appId, hosId})
}

export const getNodeCustomerList = async (args: {
    nodeId: any,
    customerName: string
}): Promise<PageListDto<Customer>> => {
    return await proxy('getDqmsCustomerList', args)
}

export const getUserBindingCustomerList = async (args: {
    hosId: any,
    orgId: any
}): Promise<{
    arr: UserBindingCustomerMo[]
}> => {
    return await proxy('getUserBindingCustomerList', args)
}

export const pullHospitalList = async (customerId: any): Promise<{
    data: boolean
}> => {
    return (await proxy('pullHospitalList?customerId='+customerId))?.data
}

export const editUserBindingCustomer = async (args: {
    hosId: any,
    orgId: any,
    uids: any[]
}): Promise<{
    data: boolean
}> => {
    return await proxy('editUserBindingCustomer', args)
}